package cn.zxf.note.note.review;

import cn.zxf.note.common.constant.CommonStatusConstant;
import lombok.AllArgsConstructor;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * Created by zengxf on 2019/4/2.
 */
@AllArgsConstructor
public enum NoteReviewStatusEnum implements CommonStatusConstant {

    INITIAL(NORMAL_CODE, "初始化"),   // 待复习
    REVIEWED(2, "已复习"),
    DELETED(DELETED_CODE, DELETED_DESC),    // 垃圾箱可见
    CLEARED(CLEARED_CODE, CLEARED_DESC)     // 用户不可见
    //
    ;

    public final Integer code;
    public final String desc;

    public static boolean isNormal(Integer status) {
        return Stream.of(INITIAL, REVIEWED)
                .filter(e -> Objects.equals(e.code, status))
                .findAny()
                .map(e -> e != null)
                .orElse(false);
    }

}
